package com.jia.configuration;

import com.jia.annotation.CustomConditionalOnClass;
import com.jia.server.impl.JettyWebServer;
import com.jia.server.impl.TomcatWebServer;
import com.jia.server.impl.UndertowWebServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebAutoConfiguration {

    @Bean
//    @Conditional(value = TomcatCondition.class)
    @CustomConditionalOnClass(value = "org.apache.catalina.startup.Tomcat")
    public TomcatWebServer tomcatWebServer() {
        return new TomcatWebServer();
    }

    @Bean
//    @Conditional(value = JettyCondition.class)
    @CustomConditionalOnClass(value = "org.eclipse.jetty.server.Server")
    public JettyWebServer jettyWebServer() {
        return new JettyWebServer();
    }

    @Bean
//    @Conditional(value = UndertowCondition.class)
    @CustomConditionalOnClass(value = "io.undertow.client.UndertowClient")
    public UndertowWebServer undertowWebServer() {
        return new UndertowWebServer();
    }


}
